package com.bhs.sansonglogistics.ui.adapter;

import android.graphics.Color;
import android.graphics.Paint;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.bhs.sansonglogistics.R;
import com.bhs.sansonglogistics.bean.PromotionPrice;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

public class LinePromotionAdapter extends BaseQuickAdapter<PromotionPrice, BaseViewHolder> {

    private int promotionType = 1;

    public LinePromotionAdapter(int layoutResId, @Nullable List<PromotionPrice> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, PromotionPrice item) {

        helper.setText(R.id.tv_title, item.getCard());
        TextView tvMoney=helper.getView(R.id.tv_money);
        tvMoney.setText(item.getPresentPrice());
        TextView tvOriginalPrice = helper.getView(R.id.tv_original_price);
        tvOriginalPrice.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
        tvOriginalPrice.setText(String.format("原价%s",item.getOriginalCost()));
        TextView tvTitle = helper.getView(R.id.tv_title);
        TextView tvType = helper.getView(R.id.tv_type);
        tvType.setText(item.getTypeName());
        if (item.isCheck()) {
            helper.setBackgroundRes(R.id.ll_main, R.drawable.border_golden_8);
            tvTitle.setTextColor(Color.parseColor("#7B4D25"));
            tvMoney.setTextColor(Color.parseColor("#FF2330"));
            helper.setTextColor(R.id.tv_money_label,Color.parseColor("#FF2330"));
            if (promotionType == 1) {
                tvTitle.setBackgroundResource(R.drawable.bg_golden_title);
            } else {
                tvTitle.setBackgroundResource(R.drawable.bg_silver_card);
            }
        } else {
            helper.setTextColor(R.id.tv_money_label,Color.parseColor("#000000"));
            tvTitle.setTextColor(Color.parseColor("#7A7A7A"));
            tvMoney.setTextColor(Color.parseColor("#000000"));
            helper.setBackgroundRes(R.id.ll_main, R.drawable.bg_promotion);
            tvTitle.setBackgroundResource(R.drawable.bg_unselected);
        }
    }

    public void setPromotionType(int promotionType) {
        this.promotionType = promotionType;
    }
}
